
import 'package:jd_shopping/HttpRequest/configApi.dart';
import 'package:jd_shopping/HttpRequest/httpRequest.dart';
import 'package:jd_shopping/HttpRequest/ResultData.dart';

class HttpRequestMethod{

   static Future<ResultData> getfocus() async{
    ResultData response = await HttpRequest.get(ConfigApi.productApi, null);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }

   static Future<ResultData> getHotProductData() async{
    ResultData response = await HttpRequest.get(ConfigApi.hotProductApi, null);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }

  static Future<ResultData> getBestProductData() async{
    ResultData response = await HttpRequest.get(ConfigApi.bestProductDataApi, null);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }

  static Future<ResultData> getPcatetData(String queryParameters) async{
    ResultData response = await HttpRequest.get(ConfigApi.pcateDataApi+'?'+'pid=$queryParameters', queryParameters);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }


  static Future<ResultData> getProductListData(String queryParameters,String queryParametersSort,int page,String search) async{
    ResultData response = await HttpRequest.get(ConfigApi.productListDataApi+'?'+'cid=$queryParameters'+'&'+'sort=$queryParametersSort'+'&'+'page=$page' + '&'+'pageSize=8'+'&'+'search=$search' , null);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }

  static Future<ResultData> getProductDetaileData(String queryParameters) async{
    ResultData response = await HttpRequest.get(ConfigApi.productDetaileDataApi+'?'+'id=$queryParameters', queryParameters);
    if(response != null && response.result){
      return  response;
    }else{
      return null;
    }
  }




}
